// 获取年月日时分秒
export function dateFilter(data){
    function add0(m){
        return m<10 ? '0'+m:m 
    }
    var time = new Date(data);
    var y = time.getFullYear();
    var m = time.getMonth()+1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y+'-'+add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm)+':'+add0(s);
}
// 获取月日时分
export function monthdayFilter(data){
    function add0(m){
        return m<10 ? '0'+m:m 
    }
    var time = new Date(data);
    var m = time.getMonth()+1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    return add0(m)+'-'+add0(d)+' '+add0(h)+':'+add0(mm);
}
// 获取年月日
export function getYearFilter(data){
    var time = new Date(data);
    var y = time.getFullYear();
    return y
}
export function getMonthFilter(data){
    var time = new Date(data);
    var m = time.getMonth()+1;
    return m
}
export function getDayFilter(data){
    var time = new Date(data);
    var d = time.getDate();
    return d
}
// 保留两位小数
export function numFilter(data){
    let num = parseFloat(data).toFixed(2)
    return num
}
// 银行卡格式处理
export function bankcardFilter(data){
    let numlist  = data+'';
    let value = numlist.replace(/\s/g,'').replace(/(\d{4})(?=\d)/g,"$1 ");
    return value
}
// 银行卡只保留最后四位格式处理
export function bankcardhidenFilter(data){
    let numlist  = data+'';
    let num = numlist.replace(/\s/g,'').replace(/(\d{4})\d+(\d{4})$/, "**** **** **** $2")
    return num
}
// 保留银行卡后四位
export function bankcardlastFilter(data){
    let numlist  = data+'';
    let num = numlist.substr(numlist.length-4)
    return num
}